import http from "@/utils/ajax/http";
import { extend } from "@/utils/extend";

const api = {
    code: {
        OK: 0,
    },
    user: {
        login: "authLogin.do?ac=login",
        tokenLogin: "tokenLogin.do",
        logout: "logout.do",
    },
    checkUpdate: "sh.do",
    editorPassword: "editPassword",
    checkField: "checkno.do",

    captch() {
        var url = "captcha.do?rd=" + Math.floor(Math.random() * 100000);
        return new Promise((resolve, reject) => {
            http.get(url).then((res) => {
                var url = res.data;
                resolve(url);
            }, reject);
        });
    },
    search: {
        select: "selectUpdateSearch.do",
        table: "tableAjax.do?a=table",
        selectView: "selectView.do",
        all: "selectAll.do",
    },
    attachment: {
        uploadUrl: "upload_re.do",
        upload(file) {
            return new Promise((resolve, reject) => {
                var formdata = new FormData();
                formdata.append("fujian", file, file.name || "tmp.png");
                http.post(api.attachment.uploadUrl, formdata)
                    .then((res) => {
                        if (res.code == api.code.OK) {
                            resolve(res.data);
                        } else {
                            reject(res.msg);
                        }
                    })
                    .catch((err) => {
                        reject(err.message);
                    });
            });
        },
    },
    admins: {
        list: "admins_list.do",
        insert: "adminsinsert.do",
        update: "adminsupdate.do",
        delete: "admins_delete.do",
        detail: "admins_detail.do",
        create: "admins_add.do",
        edit: "admins_updt.do",
    },
    yonghu: {
        list: "yonghu_list.do",
        insert: "yonghuinsert.do",
        update: "yonghuupdate.do",
        delete: "yonghu_delete.do",
        detail: "yonghu_detail.do",
        create: "yonghu_add.do",
        edit: "yonghu_updt.do",
        export: "yonghu_export.do",
    },
    rizhiguanli: {
        list: "rizhiguanli_list.do",
        insert: "rizhiguanliinsert.do",
        update: "rizhiguanliupdate.do",
        delete: "rizhiguanli_delete.do",
        detail: "rizhiguanli_detail.do",
        create: "rizhiguanli_add.do",
        edit: "rizhiguanli_updt.do",
        listtianjiaren: "rizhiguanli_list_tianjiaren.do",
        export: "rizhiguanli_export.do",
    },
    jigouxinxi: {
        list: "jigouxinxi_list.do",
        insert: "jigouxinxiinsert.do",
        update: "jigouxinxiupdate.do",
        delete: "jigouxinxi_delete.do",
        detail: "jigouxinxi_detail.do",
        create: "jigouxinxi_add.do",
        edit: "jigouxinxi_updt.do",
        listtianjiaren: "jigouxinxi_list_tianjiaren.do",
        export: "jigouxinxi_export.do",
    },
    guandaoxinxi: {
        list: "guandaoxinxi_list.do",
        insert: "guandaoxinxiinsert.do",
        update: "guandaoxinxiupdate.do",
        delete: "guandaoxinxi_delete.do",
        detail: "guandaoxinxi_detail.do",
        create: "guandaoxinxi_add.do",
        edit: "guandaoxinxi_updt.do",
        export: "guandaoxinxi_export.do",
    },
    xiangmuxinxi: {
        list: "xiangmuxinxi_list.do",
        insert: "xiangmuxinxiinsert.do",
        update: "xiangmuxinxiupdate.do",
        delete: "xiangmuxinxi_delete.do",
        detail: "xiangmuxinxi_detail.do",
        create: "xiangmuxinxi_add.do",
        edit: "xiangmuxinxi_updt.do",
        export: "xiangmuxinxi_export.do",
    },
    chuanganqi: {
        list: "chuanganqi_list.do",
        insert: "chuanganqiinsert.do",
        update: "chuanganqiupdate.do",
        delete: "chuanganqi_delete.do",
        detail: "chuanganqi_detail.do",
        create: "chuanganqi_add.do",
        edit: "chuanganqi_updt.do",
        export: "chuanganqi_export.do",
    },
    gongyeguandaomoxing: {
        list: "gongyeguandaomoxing_list.do",
        insert: "gongyeguandaomoxinginsert.do",
        update: "gongyeguandaomoxingupdate.do",
        delete: "gongyeguandaomoxing_delete.do",
        detail: "gongyeguandaomoxing_detail.do",
        create: "gongyeguandaomoxing_add.do",
        edit: "gongyeguandaomoxing_updt.do",
        export: "gongyeguandaomoxing_export.do",
    },
    chuanganqimoxing: {
        list: "chuanganqimoxing_list.do",
        insert: "chuanganqimoxinginsert.do",
        update: "chuanganqimoxingupdate.do",
        delete: "chuanganqimoxing_delete.do",
        detail: "chuanganqimoxing_detail.do",
        create: "chuanganqimoxing_add.do",
        edit: "chuanganqimoxing_updt.do",
        export: "chuanganqimoxing_export.do",
    },
    baojing: {
        list: "baojing_list.do",
        insert: "baojinginsert.do",
        update: "baojingupdate.do",
        delete: "baojing_delete.do",
        detail: "baojing_detail.do",
        create: "baojing_add.do",
        edit: "baojing_updt.do",
    },
    shishijiance: {
        list: "shishijiance_list.do",
        insert: "shishijianceinsert.do",
        update: "shishijianceupdate.do",
        delete: "shishijiance_delete.do",
        detail: "shishijiance_detail.do",
        create: "shishijiance_add.do",
        edit: "shishijiance_updt.do",
    },
};

export default api;
